<?php
// this just ensures noone can run this script without going through the application
if( !defined('PIH' ) ) {
    header('HTTP/1.0 404 Not Found');
    exit();
}
?>
<?php echo $this->render('news_header')?>
<h2>Edit news article</h2>
<form action="<?php echo $this->url('news')?>" method="post">
    <input type="hidden" name="news_id" value="<?php echo $news_item->news_id?>" />
    <fieldset>
        <legend>Edit &quot;<?php echo htmlspecialchars($news_item->headline)?>&quot;</legend>
        <p>
            <label for="headline">Headline</label>
            <br /><input id="headline" name="headline" class="longtext" value="<?php echo htmlspecialchars($news_item->headline)?>" />
        </p>
        <p>
            <label for="summary">Short (max 255 characters) Summary</label>
            <br /><textarea id="summary" name="summary" class="longtext" rows="4"><?php echo htmlspecialchars($news_item->summary)?></textarea>
        </p>
        <p>
            <label for="details">News article text (HTML allowed)</label>
            <br /><textarea id="details" name="details" class="longtext" rows="20"><?php echo htmlspecialchars($news_item->details)?></textarea>
            <br />Use HTML tags to format this content.
        </p>
        <p>
            <label for="status">Article Status</label>
            <br />
            <select name="status" id="status">
            <?php foreach( array('unpublished', 'published', 'archived', 'hidden') as $status ) {?>
                <option value="<?php echo $status?>"<?php if( $status == $news_item->status ) echo ' selected="selected" '?>><?php echo htmlspecialchars($status)?></option>
            <?php } ?>
            </select>
            <br />Select the status of this article. 'Archived' news is displayed only on the main news page.
        </p>
        <p>
            <label for="published">Date Published</label>
            <br />
            <input id="published" type="text" name="published" value="<?php echo htmlspecialchars($news_item->published)?>" />
            <br />Enter the date this article should be visible from in the format "YYYY-MM-DD", eg. 2009-04-20
        </p>
        <input type="submit" name="update" value="Save Changes" />
    </fieldset>
    <fieldset>
        <legend>Permanently delete news article</legend>
        <input type="submit" name="delete" value="Delete News" onclick="return confirm('Are you sure you want to permanently delete this news item?');" />
    </fieldset>
</form>